import request from '@/utils/request'
import axios from 'axios'

// 登陆的API接口
export const loginAPI = data => {
  return request.post('/v1_0/authorizations', data)
}

// 请求用户基本信息
export const getUserInfoAPI = () => {
  return request.get('/v1_0/user')
}

// 获取用户简介信息
export const getUserProfileAPI = () => {
  return request.get('/v1_0/user/profile')
}

// 更新用户简介API
export const updateUserProfileAPI = (obj) => {
  return request.patch('/v1_0/user/profile', obj)
}

// 修改头像的 API
export const updateUserAvatarAPI = fd => {
  return request.patch('/v1_0/user/photo', fd)
}

// 交换 token API
export const exchangeTokenAPI = refreshToken => {
  return axios({
    method: 'PUT',
    url: 'http://toutiao-app.itheima.net/v1_0/authorizations',
    // 请求头对象
    headers: {
      Authorization: `Bearer ${refreshToken}`
    }
  })
}
